home *** CD-ROM | disk | FTP | other *** search
/ Dr. Windows 3 / dr win3.zip / dr win3 / PROGRAMR / OLE2BOOK.ZIP / CHAP08.ZIP / CHAP08 / PATRON / PAGES.H < prev    next >
C/C++ Source or Header  |  1993-06-07  |  13KB  |  391 lines

  1. /*
  2.  * PAGES.H
  3.  * Modifications for Chapter 8
  4.  *
  5.  * Definitions and function prototypes for the Pages window control
  6.  * as well as the CPage and CTenant classes.
  7.  *
  8.  * Copyright (c)1993 Microsoft Corporation, All Rights Reserved
  9.  *
  10.  * Kraig Brockschmidt, Software Design Engineer
  11.  * Microsoft Systems Developer Relations
  12.  *
  13.  * Internet  :  kraigb@microsoft.com
  14.  * Compuserve:  >INTERNET:kraigb@microsoft.com
  15.  */
  16.  
  17.  
  18. #ifndef _PAGES_H_
  19. #define _PAGES_H_
  20.  
  21. //We need this for UICursorLoad and new-style cursors.
  22. #include <bttncur.h>
  23.  
  24.  
  25. //Versioning.
  26. #define VERSIONMAJOR                2
  27. #define VERSIONMINOR                0
  28. #define VERSIONCURRENT              0x00020000
  29.  
  30. //Classname
  31. #define SZCLASSPAGES                "pages"
  32.  
  33. #define HIMETRIC_PER_INCH           2540
  34. #define LOMETRIC_PER_INCH           254
  35. #define LOMETRIC_BORDER             60          //Border around page
  36.  
  37.  
  38. //Window extra bytes and offsets
  39. #define CBPAGESWNDEXTRA             (sizeof(LONG))
  40. #define PAGEWL_STRUCTURE            0
  41.  
  42.  
  43.  
  44. /*
  45.  * Tenant class describing an individual piece of data in a page.
  46.  * It knows where it sits, what object is inside of it, and what
  47.  * its idenitifer is such that it can find it's storage within a page.
  48.  */
  49.  
  50. //Patron Objects clipboard format
  51. typedef struct tagPATRONOBJECT
  52.     {
  53.     POINTL      ptl;        //Location of object
  54.     POINTL      ptlPick;    //Pick point from drag-drop operation.
  55.     SIZEL       szl;        //Extents of object (absolute)
  56.     FORMATETC   fe;         //Actual object format.
  57.     } PATRONOBJECT, FAR * LPPATRONOBJECT;
  58.  
  59.  
  60.  
  61. //Values for hit-testing, drawing, and resize-tracking tenants
  62. #define CXYHANDLE       5
  63.  
  64. //Tenant creation types (not persistent)
  65. typedef enum
  66.     {
  67.     TENANTTYPE_NULL=0,
  68.     TENANTTYPE_STATIC,
  69.     } TENANTTYPE, FAR * LPTENANTTYPE;
  70.  
  71.  
  72. //State flags
  73. #define TENANTSTATE_DEFAULT      0x00000000
  74. #define TENANTSTATE_SELECTED     0x00000001
  75.  
  76.  
  77. class __far CTenant
  78.     {
  79.     private:
  80.         HWND            m_hWnd;             //Pages window, same as CPages.
  81.         DWORD           m_dwID;             //Persistent DWORD identifier
  82.         DWORD           m_cOpens;           //Count calls to FOpen.
  83.  
  84.         BOOL            m_fInitialized;     //Something here?
  85.         LPUNKNOWN       m_pObj;             //The object that lives here.
  86.         LPSTORAGE       m_pIStorage;        //Sub-storage for this tenant
  87.  
  88.         FORMATETC       m_fe;               //As used to create the object.
  89.         DWORD           m_dwState;          //State flags
  90.         RECTL           m_rcl;              //Space of this object.
  91.  
  92.         class CPages FAR *m_pPG;            //Pages window
  93.  
  94.     protected:
  95.         HRESULT CreateStatic(LPDATAOBJECT, LPFORMATETC, LPUNKNOWN FAR *);
  96.  
  97.     public:
  98.         CTenant(DWORD, HWND, CPages FAR *);
  99.         ~CTenant(void);
  100.  
  101.         DWORD   GetID(void);
  102.         UINT    GetStorageName(LPSTR);
  103.         UINT    UCreate(TENANTTYPE, LPVOID, LPFORMATETC, LPPOINTL
  104.                     , LPSIZEL, LPSTORAGE, LPPATRONOBJECT, DWORD);
  105.         BOOL    FLoad(LPSTORAGE, LPFORMATETC, LPRECTL);
  106.         BOOL    FOpen(LPSTORAGE);
  107.         void    Close(BOOL);
  108.         BOOL    Update(void);
  109.         void    Destroy(LPSTORAGE);
  110.  
  111.         void    Select(BOOL);
  112.         BOOL    Activate(DWORD);
  113.         void    Draw(HDC, DVTARGETDEVICE FAR *, HDC, int, int, BOOL, BOOL);
  114.         void    Repaint(void);
  115.         void    Invalidate(void);
  116.  
  117.         void    ObjectGet(LPUNKNOWN FAR *);
  118.         void    FormatEtcGet(LPFORMATETC, BOOL);
  119.         void    SizeGet(LPSIZEL, BOOL);
  120.         void    SizeSet(LPSIZEL, BOOL);
  121.         void    RectGet(LPRECTL, BOOL);
  122.         void    RectSet(LPRECTL, BOOL);
  123.     };
  124.  
  125.  
  126. typedef CTenant FAR * LPTENANT;
  127.  
  128. //Return codes for UCreate
  129. #define UCREATE_FAILED              0
  130. #define UCREATE_GRAPHICONLY         1
  131. #define UCREATE_PLACEDOBJECT        2
  132.  
  133.  
  134.  
  135. typedef struct __far tagTENANTLIST
  136.     {
  137.     DWORD       cTenants;
  138.     DWORD       dwIDNext;
  139.     } TENANTLIST, FAR *LPTENANTLIST;
  140.  
  141.  
  142. /*
  143.  * Persistent information we need to save for each tenant, which is done
  144.  * in the tenant list instead of with each tenant.  Since this is a small
  145.  * structure it's best not to blow another stream for it (overhead).
  146.  */
  147. typedef struct tagTENANTINFO
  148.     {
  149.     DWORD       dwID;
  150.     RECTL       rcl;
  151.     FORMATETC   fe;     //Excludes ptd
  152.     } TENANTINFO, FAR *LPTENANTINFO;
  153.  
  154.  
  155. #define SZSTREAMTENANTLIST        "Tenant List"
  156.  
  157.  
  158.  
  159.  
  160. /*
  161.  * Page class describing an individual page and what things it contains,
  162.  * managing an IStorage for us.
  163.  *
  164.  * A DWORD is used to identify this page as the name of the storage
  165.  * is the string form of this ID.  If we added a page every second,
  166.  * it would take 136 years to overrun this counter, so we can
  167.  * get away with saving it persistently.  I hope this software is
  168.  * obsolete by then.
  169.  */
  170.  
  171. class __far CPage
  172.     {
  173.     private:
  174.         HWND        m_hWnd;             //Pages window, same as CPages.
  175.         DWORD       m_dwID;             //Persistent DWORD identifier
  176.         LPSTORAGE   m_pIStorage;        //Sub-storage for this page.
  177.         DWORD       m_cOpens;           //Calls to FOpen.
  178.  
  179.         class CPages FAR *m_pPG;        //Pages window
  180.  
  181.         DWORD       m_dwIDNext;
  182.         DWORD       m_cTenants;
  183.         HWND        m_hWndTenantList;   //Listbox that manages our tenant list
  184.  
  185.         UINT        m_iTenantCur;
  186.         LPTENANT    m_pTenantCur;
  187.  
  188.         UINT        m_uHTCode;          //Last hit-test on mouse move.
  189.         UINT        m_uSizingFlags;     //Restrictions on sizing motion.
  190.         BOOL        m_fTracking;        //Tracking resize?
  191.         RECTL       m_rclOrg;           //Original before tracking
  192.         RECTL       m_rcl;              //Tracking rectangle.
  193.         RECTL       m_rclBounds;        //Boundaries for size tracking.
  194.         HDC         m_hDC;              //Tracking hDC.
  195.  
  196.     protected:
  197.         BOOL         FTenantGet(UINT, LPTENANT FAR *, BOOL);
  198.         BOOL         FTenantAdd(UINT, DWORD, LPTENANT FAR *);
  199.         LPDATAOBJECT TransferObjectCreate(LPPOINTL);
  200.  
  201.         //PAGEMOUS.CPP
  202.         UINT         TenantFromPoint(UINT, UINT, LPTENANT FAR *);
  203.         //CHAPTER8MOD
  204.         BOOL         DragDrop(UINT, UINT, UINT);
  205.         //End CHAPTER8MOD
  206.  
  207.     public:
  208.         CPage(DWORD, HWND, class CPages FAR *);
  209.         ~CPage(void);
  210.  
  211.         DWORD       GetID(void);
  212.         BOOL        FOpen(LPSTORAGE);
  213.         void        Close(BOOL);
  214.         BOOL        Update(void);
  215.         void        Destroy(LPSTORAGE);
  216.         UINT        GetStorageName(LPSTR);
  217.  
  218.         void        Draw(HDC, int, int, BOOL, BOOL);
  219.  
  220.         BOOL        TenantCreate(TENANTTYPE, LPVOID, LPFORMATETC
  221.                         , LPPATRONOBJECT, DWORD);
  222.         BOOL        TenantDestroy(void);
  223.         BOOL        TenantClip(BOOL);
  224.         BOOL        FQueryObjectSelected(HMENU);
  225.  
  226.         //PAGEMOUSE.CPP
  227.         BOOL        OnLeftDown(UINT, UINT, UINT);
  228.         BOOL        OnLeftDoubleClick(UINT, UINT, UINT);
  229.         BOOL        OnLeftUp(UINT, UINT, UINT);
  230.         void        OnNCHitTest(UINT, UINT);
  231.         BOOL        OnSetCursor(UINT);
  232.         void        OnMouseMove(UINT, int, int);
  233.     };
  234.  
  235. typedef CPage FAR * LPPAGE;
  236.  
  237.  
  238.  
  239. /*
  240.  * Structures to save with the document describing the device
  241.  * configuration and pages that we have.  This is followed by
  242.  * a list of DWORD IDs for the individual pages.
  243.  */
  244.  
  245. typedef struct __far tagDEVICECONFIG
  246.     {
  247.     DEVMODE     dm;
  248.     char        szDriver[CCHDEVICENAME];
  249.     char        szDevice[CCHDEVICENAME];
  250.     char        szPort[CCHDEVICENAME];
  251.     } DEVICECONFIG, FAR * LPDEVICECONFIG;
  252.  
  253.  
  254. typedef struct __far tagPAGELIST
  255.     {
  256.     DWORD       cPages;
  257.     DWORD       iPageCur;
  258.     DWORD       dwIDNext;
  259.     } PAGELIST, FAR *LPPAGELIST;
  260.  
  261.  
  262. //PAGEWIN.CPP
  263. LRESULT __export FAR PASCAL PagesWndProc(HWND, UINT, WPARAM, LPARAM);
  264. BOOL    __export FAR PASCAL AbortProc(HDC, int);
  265. BOOL    __export FAR PASCAL PrintDlgProc(HWND, UINT, WPARAM, LPARAM);
  266. void